#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <time.h>

#define LOG_FILE_PATH ("./err.log")

#define LOG(str, args...) do{\
    time_t now; \
    struct tm *tm; \
    time(&now); \
    tm = localtime(&now); \
    FILE* f = fopen(LOG_FILE_PATH, "a+"); \
    fprintf(f,"[%04d-%02d-%02d %02d:%02d:%02d ] " str, tm->tm_year+1900, tm->tm_mon+1, tm->tm_mday,\
            tm->tm_hour, tm->tm_min, tm->tm_sec, args); \
    fclose(f); \
}while(0)

int main(int argc, char** argv) {
    LOG("exit code: %d, %d\n", 9, 10);
    return 0;
}
